package com.wk.code.wkserver.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: wangqiang
 * @create: 2021-08-26 16:20
 */
public class RegUtils {

    public static final String regEx = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";

    static String regExp = "^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(166)|(17[3,5,6,7,8])|(18[0-9])|(19[8,9]))\\d{8}$";


    /**
     * 判断邮箱地址格式
     *
     * @param email 邮箱地址
     * @return boolean
     */
    public static boolean isEmail(String email) {
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(email);
        return m.matches();
    }


    /**
     * 判断手机号
     *
     * @param number 手机号
     * @return boolean
     */
    public static boolean isMobile(String number) {
        Pattern p = Pattern.compile(regExp);
        Matcher m = p.matcher(number);
        return m.matches();
    }

}
